{% extends "shop/base.html" %}
{% load i18n %}
{% load satchmo_currency %}
{% load satchmo_order %}

{% block navbar %}
   <li class="first"><a href="{{ shop_base }}/">{% trans "Home" %}</a></li>
   <li><a href="{% url satchmo_account_info %}">{% trans "Account" %}</a></li>
   <li>{% trans "Order History" %}</li>
{% endblock %}

{% block content %}
<div id="orderhistory">
    <h2>{% trans "Order History" %}</h2>
    {% if orders %}
        <table class="ordertable">
            <thead>
            <tr>
                <th>{% trans 'Order #' %}</th>
                <th>{% trans 'Status' %}</th>
                <th>{% trans 'Date' %}</th>
                <th>{% trans 'Items' %}</th>
                <th>{% trans 'Total' %}</th>
            </tr>
            </thead>
            <tbody>
            {% for order in orders %}
            <tr>
                <td class="ordernumber">
                    <a href="{% url satchmo_order_tracking order.id %}">{{ order.id }}
                </td>
                <td class="orderstatus">
                    {{ order.status }}
                </td>
                <td class="orderdate">
                    {{ order.time_stamp|date:"F jS Y H:i" }}
                </td>
                <td class="orderitems">
                    {% for item in order.orderitem_set.all %}
                    {% if not forloop.first %}<br/>{% endif %}
                    <span class="orderitemqty">{{item.quantity}}</span> <span class="orderitem">{{ item }}<span> 
                    {% endfor %}
                </td>
                <td class="ordertototal">
                    {{order.total|currency}}
                </td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
    {% else %}
        <p>{% trans "You haven't made any orders yet." %}</p>
    {% endif %}
</div>
{% endblock %}

